package com.ios.common.login.action;

import org.springframework.beans.factory.annotation.Autowired;

import com.ios.common.action.CommonAction;
import com.ios.common.login.service.ILoginService;
import com.ios.common.login.vo.LoginUserVO;

public class LoginAction extends CommonAction {

	private static final long serialVersionUID = 1L;

	@Autowired
	private ILoginService loginService;

	private LoginUserVO userVO;

	public static final String USER_INFO = "user_info";

	public LoginAction() {
		userVO = new LoginUserVO();
	}

	public String doLogin() {
		LoginUserVO vo = this.loginService.queryUserInfoByUserCodeAndPassword(userVO.getIosSysUser().getUserCode(), userVO
				.getIosSysUser().getPassword());
		if (vo == null) {
			this.alert("不存在该用户");
			return "user_login";
		} else {
			this.getRequest().getSession().setAttribute(LoginAction.USER_INFO, vo);
			return "login_success";
		}
	}

	public void setLoginService(ILoginService loginService) {
		this.loginService = loginService;
	}

	public LoginUserVO getUserVO() {
		return userVO;
	}

	public void setUserVO(LoginUserVO userVO) {
		this.userVO = userVO;
	}

}
